package com.example.xf.test;

import java.util.ArrayList;
import java.util.List;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;

import com.emm.yixun.mobile.R;
import com.emm.yixun.mobile.application.EmmApplication;
import com.emm.yixun.mobile.base.BaseActivity;

/**
 * 
 * <p><b>Title：</b> 弹出框 </p>
 * <p><b>Description：</b> 公用弹出框 </p>
 * @author tangxin
 * @date 2016年12月6日 下午3:51:48
 */
public class PopuActivity extends BaseActivity {

	ListView listviewd;

	Button button1;

	// 可以添加范围控制，点击消失
	int i = 0;

	@Override
	protected void onResume() {
		BaseActivity.activity = this; // TODO Auto-generated method stub
		super.onResume();
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.popu_activitydf);
		BaseActivity.activity = this;
		listviewd = (ListView) findViewById(R.id.listviewd);
		button1 = (Button) findViewById(R.id.button1);

		button1.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				i++;
				if (i % 2 == 0) {
					listviewd.setVisibility(View.VISIBLE);
				} else {
					listviewd.setVisibility(View.GONE);
				}
			}
		});

		List<String> a = new ArrayList<String>();
		a.add("1");
		a.add("2");
		a.add("3");
		a.add("4");

		listviewd.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, a));
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {

		if (keyCode == event.KEYCODE_BACK) {
			finish();
			EmmApplication.startIntentAnim2S(PopuActivity.this);
		}

		return true;
	}

}
